/*
*******************************************************************************
* Copyright (c) 2023 by M5Stack
*                  Equipped with M5StickC sample source code
*                          配套  M5StickC 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/m5stickc
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/m5stickc
*
* Product:  Light.  环境光传感器
* Date: 2021/8/18
*******************************************************************************
  Please connect to Port A,Use the Light Unit screen to display the current
ambient lighting value 请连接端口 A ,使用Light Unit 屏幕显示当前环境光照值。
*/

#include <M5StickC.h>

void setup() {
    M5.begin();             // Init M5StickC.  初始化M5StickC
    M5.Lcd.setRotation(3);  // Rotate the screen.  旋转屏幕
    M5.Lcd.printf("UNIT_LIGHT EXAMPLE\n\n");
    M5.Lcd.println("Analog:");
    M5.Lcd.println("Digital:");
    pinMode(32, INPUT);  // Set pin 26 as input mode.  设置引脚26为输入模式
}

void loop() {
    static uint16_t digitalRead_value = 0, analogRead_value = 0;
    analogRead_value = analogRead(33);  // Store the analog quantity read from
                                        // pin 33.  将33号引脚读取到的模拟量存储
    digitalRead_value = digitalRead(
        32);  // Store the number read from pin 32. 将32号引脚读取到的数字量存储
    M5.Lcd.setCursor(50, 15);
    M5.Lcd.printf("%d\n", analogRead_value);
    M5.Lcd.setCursor(50, 25);
    M5.Lcd.printf("%d\n", digitalRead_value);
    delay(10);
}
